package com.banciyuan.bcywebview.biz.write;

import android.content.Intent;
import android.view.View;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.factory.TimelineFactory;
import com.banciyuan.bcywebview.biz.detail.complex.ComplexDetailActivity;
import com.banciyuan.bcywebview.biz.write.write.WriteActivity;
import com.banciyuan.bcywebview.biz.write.write.WriteTagActivity;
import com.banciyuan.bcywebview.utils.constants.MyConstants;
import com.google.gson.Gson;

import org.json.JSONObject;

/**
 * Created by hy on 2016/5/25.
 */
public class DailyEditTagActivity extends WriteTagActivity {
    private String ud_id;

    @Override
    protected void initArgs() {
        super.initArgs();
        ud_id = getIntent().getStringExtra("ud_id");
    }

    @Override
    protected void beginPost() {
        mDialog.show();
        String tempWork = worklist.contains(auto_text.getText().toString()) ? auto_text.getText().toString() : "";
        mHelper.doEditPush(ud_id, content, tempWork, new Gson().toJson(mAuthority));
    }

    @Override
    protected void initUi() {
        super.initUi();
        findViewById(R.id.rl_recommend).setVisibility(View.GONE);
        findViewById(R.id.relativeLayout).setVisibility(View.GONE);
    }

    @Override
    public void pushSuccess(String dataId) {
        try {
            if (!DailyEditTagActivity.this.isFinishing()) {
                mDialog.dismiss();
            }
            Intent intent = new Intent();
            intent.setClass(this, ComplexDetailActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(MyConstants.UDIDVALUE, new JSONObject(dataId).getString("ud_id"));
            intent.putExtra(MyConstants.TIMELINETYPE, TimelineFactory.TIMELINE_TYPE_DAILY);
            startActivityForResult(intent, WriteActivity.WRITE_ACTIVITY);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
